/*
 * LoginController.java
 *
 * Created on 10 de Julho de 2007, 10:57
 */

package br.unifor.finance.presentation.controller;

import br.unifor.finance.presentation.command.LoginCommand;
import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author Leonardo
 * @version
 */
public class LoginController extends HttpServlet {
  
  public void service(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
      
    boolean hasUserParameter = request.getParameter("usuario") != null
            && !"".equals(request.getParameter("usuario"));
    
    boolean hasPasswordParameter = request.getParameter("senha") != null
            && !"".equals(request.getParameter("senha"));
            
    if(hasUserParameter && hasPasswordParameter) {
      LoginCommand cmd = new LoginCommand();
      cmd.login(request, response);
    }  
    else
      request.getRequestDispatcher("/WEB-INF/paginas/login.jsp").forward(request, response);      
  }
}
